package table

import (
	"errors"
	"pd/server/com/db"
)

func GetLoginInfo(userId int64) (paUserId int64, roleList []int64, err error) {
	conn, err := db.GetPdMasterConn()
	if err != nil {
		return
	}
	q := conn.Conn.NewSession()
	exist, err := q.Table("user").Where("id = ?", userId).Select("pa_user_id").Get(&paUserId)
	if err != nil {
		return
	}
	if !exist {
		err = errors.New("Authorization ERROR")
		return
	}
	if err = q.Table("role_user_map").Where("user_id = ?", userId).Select("role_id").Find(&roleList); err != nil {
		return
	}
	return
}
